//女巫
module.exports = function(room,chair) {
	var basic = require("./roleBasic.js")
	basic.call(this,chair)
	console.log(basic)
	this.name = "女巫"			//角色名
	this.role = "witch"			//角色类型
	this.camp = "protoss"   	//阵营	werewolf  protoss  villager
	this.survive = true 	  	//存活状态
	this.votePower = true   	//投票权
	this.showRole = "normal"	//显示状态
	this.save = true 			//解药
	this.poison = true 			//毒药
	this.state = true 			//本轮操作状态
	//角色行动
	this.action = function(type,target,cb) {
		if(room.state != room.NIGHT_WITCH_STATE){
			cb(false,"不在女巫阶段")
			return
		}
		if(this.role !== "witch"){
			cb(false,"身份错误：witch : "+this.role)
			return
		}
		if(!this.survive){
			cb(false,"已死亡")
			return
		}
		if(!this.state){
			cb(false,"本轮已操作")
			return
		}
		this.state = false
		if(type == "save"){
			if(!this.save){
				cb(false,"已用过解药")
				return
			}
			this.save = false
			room.witchAction["type"] = type
		}else if(type == "poison"){
			if(!this.poison){
				cb(false,"已用过毒药")
				return
			}
			if(typeof(target) != "number" || !room.roleList[target].survive){
				cb(false,"目标错误 : "+target)
				return
			}
			this.poison = false
			room.witchAction["type"] = type
			room.witchAction["target"] = target
		}else{
			cb(false,"type error : "+type)
			return
		}
		cb(true)
		room.nextTime = 3000
	}
	//获取自身信息
	this.getRoleInfo = function() {
		var info = {
			name : this.name,
			role : this.role,
			camp : this.camp,
			survive : this.survive,
			votePower : this.votePower,
			showRole : this.showRole,
			save : this.save,
			poison : this.poison
		}
		return info
	}
}